import request from '@/utils/request'

// 登录接口
export const userLoginService = (loginForm: Object) => {
  return request.post(`/student/login`, loginForm)
}

// 获取公告接口
export const userGetNotificationService = (searchForm: Object) => {
  return request.post(`/student/notification`, searchForm)
}

// 获取话题列表接口
export const userGetTopicListService = (type: Number) => {
  return request.get(`/student/topic/${type}`)
}

// 获取话题详细接口
export const userGetTopicDetailService = (id: any) => {
  return request.get(`/student/topic`, {
    params: {
      id: id
    }
  })
}

// 获取评论接口，一次5条
export const userGetCommentListService = (currentPage: Number, topicId: any) => {
  return request.get(`/student/topic/comment`, {
    params: {
      currentPage,
      topicId
    }
  })
}

// 发表评论接口
export const userAddCommentService = (content: String, topicId: any) => {
  console.log(content, topicId)
  return request.put(`/student/topic`, {
    content: content,
    topicId: topicId
  })
}

// 暂存话题草稿接口
export const userSaveTopicDraftService = (topicForm: Object) => {
  return request.post('/student/topic/draft', topicForm)
}

// 获取草稿
export const userGetTopicDraftService = () => {
  return request.get(`/student/topic/draft`)
}

// 发布话题
export const userPublishTopicService = (topicForm: Object) => {
  return request.post(`/student/topic`, topicForm)
}

// 获取视频列表
export const userGetVideoList = (form: Object) => {
  return request.post(`/student/video`, form)
}

// 获取具体的视频播放
export const userGetVideoDetailService = (id: any) => {
  console.log(id)
  return request.get(`/student/video/${id}`)
}

// 获取文档列表
export const userGetDocumentList = (form: Object) => {
  return request.post(`/student/document`, form)
}

// 获取具体的文档预览
export const userGetDocumentDetailService = (id: any) => {
  console.log(id)
  return request.get(`/student/document/${id}`)
}

// 获取课件列表
export const userGetCoursewareList = (form: Object) => {
  return request.post(`/student/courseware`, form)
}

// 获取具体的课件预览
export const userGetCoursewareDetailService = (id: any) => {
  console.log(id)
  return request.get(`/student/courseware/${id}`)
}

// 获取试卷列表
export const userGetPaperListService = (form: Object) => {
  return request.post(`/student/test/paper`, form)
}

// 获取题目列表
export const userGetQuestionListService = (id: any) => {
  return request.get(`/student/test/question/${id}`)
}

// 保存学生作答信息
export const userSaveAnswerService = (form: Object, paperId: any) => {
  return request.post(`/student/test/question/save`, form, {
    params: {
      paperId
    }
  })
}

// 获取已经作答的题目选项
export const userGetAnswerService = (id: any) => {
  return request.get(`/student/test/question/answer/${id}`)
}

export const userSubmitAnswerService = (paperId: any) => {
  console.log(paperId)
  return request.put(`/student/test/question/answer/${paperId}`)
}

// 获取用户的基本信息
export const userGetUserInfoService = () => {
  return request.get('/student/user')
}

// 修改用户信息
export const userUpdateUserInfoService = (form: Object) => {
  return request.post(`/student/user`, form)
}

// 用户修改密码
export const userEditPasswordService = (passwordForm: Object) => {
  return request.post(`/student/user/password`, passwordForm)
}

// 获取试卷的正确答案和解析
export const userGetCorrectAnswerService = (id: any) => {
  return request.get(`/student/test/paper/correctAnswer/${id}`)
}

// 获取试卷的分数
export const userGetScoreService = (id: any) => {
  return request.get(`/student/test/paper/score/${id}`)
}

// 统计每个模块的内容数量
export const userGetContentCountService = () => {
  return request.get(`/student/statistics/count`)
}

// 获取违规信息
export const userGetIllegalListService = () => {
  return request.get(`/student/topic/illegal`)
}

export const userRegisterService = (form: Object) => {
  return request.post(`/student/register`, form)
}
